package cn.com.mrzheng.web.controller;

import cn.com.mrzheng.web.controller.base.BaseController;
import cn.com.mrzheng.web.entity.Auth;
import cn.com.mrzheng.web.server.impl.AuthService;
import cn.com.mrzheng.web.utils.Envelope;
import cn.com.mrzheng.web.utils.ServiceApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

// rest风格控制器
@RestController
//  跨域调用
@CrossOrigin(origins = ServiceApi.Config.CrossOrigin, maxAge = 3600)
public class AuthController extends BaseController<Auth, AuthService> {

    @Autowired
    AuthService Server;

    // 获取列表
    @RequestMapping(value = ServiceApi.Auth.LIST, method = RequestMethod.GET)
    public Envelope list(String filter, String currentPage, String pageSize){
        return super.list(filter,currentPage,pageSize);
    }

    // 保存
    @RequestMapping(value = ServiceApi.Auth.SAVE, method = RequestMethod.POST)
    public Envelope saveEntity(String datajson){
        return super.saveEntity(datajson);
    }

    // 删除
    @RequestMapping(value = ServiceApi.Auth.DELETE, method = RequestMethod.GET)
    public Envelope deleteEntity(String id){
        return super.deleteEntity(id);
    }

    // 查找编辑数据
    @RequestMapping(value = ServiceApi.Auth.GET, method = RequestMethod.GET)
    public Auth getEntity(String id){
        Auth role = Server.getEntity(id);
        return role;
    }

}
